package com.prs.crm.dao.personalset.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.personalset.DefaultCitySetDao;
import com.prs.crm.domain.personalset.DefaultCitySet;

public class DefaultCitySetDaoImpl extends BaseDaoImpl<DefaultCitySet> implements DefaultCitySetDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<DefaultCitySet> getAllDefaultCitySet() {
		Criteria criteria=this.getSession().createCriteria(DefaultCitySet.class);
		return criteria.list();
	}

	@Override
	public DefaultCitySet getDefaultCitySet(final String type) {
		Criteria criteria=this.getSession().createCriteria(DefaultCitySet.class)
		.add(Restrictions.eq("type", type));
		List result=criteria.list();
		if(result==null || result.size()==0){
			return null;
		}
		return (DefaultCitySet) criteria.list().get(0);
	}

}
